<template>
	<view class="details">
		<view class="ul">
			<view><image :src="initData.image" mode="widthFix" class="img" /></view>
			<view>
				<text class="text">订单号：</text>
				{{ initData.orderSn }}
			</view>
			<view>
				<text class="text">商品货号：</text>
				{{ initData.goodsSn }}
			</view>
			<view>
				<text class="text">供应商信息：</text>
				{{ initData.supplierName }}
			</view>
			<view>
				<text class="text">数量：</text>
				1件
			</view>
			<view>
				<text class="text">客户名称：</text>
				{{ initData.contactUser }}
			</view>
			<view>
				<text class="text">联系电话：</text>
				{{ initData.contactPhone }}
			</view>
			<view>
				<text class="text">订单来源：</text>
				{{ initData.contactPhone }}
			</view>
			<view>
				<text class="text">下单时间：</text>
				{{ initData.createdTime }}
			</view>
			<view>
				<text class="text">审核时间：</text>
				{{ initData.createdTime }}
			</view>
			<view>
				<text class="text">身高：</text>
				{{ initData.height }}
			</view>
			<view>
				<text class="text">体重：</text>
				{{ initData.weight }}
			</view>
			<view v-for="item in initData.sku" :key="item.value">
				<text class="text">{{ item[0] }}：</text>
				{{item[1]}}
			</view>
			<view>
				<text class="text">下单人：</text>
				{{ initData.placeOrderPerson }}
			</view>
			<view>
				<text class="text">所属代理：</text>
				{{ initData.expressSn }}
			</view>
			<view>
				<text class="text">收货地址：</text>
				{{ initData.province }}{{ initData.city }}{{ initData.region }} {{ initData.addrDetail }}
			</view>
			<view>
				<text class="text">备注：</text>
				{{ initData.remark }}
			</view>
			<view v-if="!is_audit">
				<text class="text">客服备注：</text>
				{{ initData.remark }}
			</view>
			<view v-if="!is_audit"><text class="text">物流信息：</text></view>
			<view v-if="is_audit" class="li">
				<text class="text">客服备注：</text>
				<textarea value="" placeholder="" v-model="remark" />
			</view>
			<view class="button" v-if="is_audit">
				<view class="pass" @click="pass(1)">通 过</view>
				<view class="refuse" @click="pass(0)">不通过</view>
			</view>
		</view>

		<view class="go-top" v-show="is_go_top" @click="backTop"><image src="/static/img/go_top.png" /></view>
	</view>
</template>

<script>
import { uniIcons, uniPopup } from '@dcloudio/uni-ui';
import order from '../../servers/servers/order.js';
export default {
	components: { uniIcons, uniPopup },
	data() {
		return {
			initData: '',
			id: '',
			is_audit: true, //是否待审核
			index: 0,
			is_go_top: false,
			remark:''
		};
	},
	onPageScroll: function(e) {
		//nvue暂不支持滚动监听，可用bindingx代替
		if (e.scrollTop > 200) {
			this.is_go_top = true;
		} else {
			this.is_go_top = false;
		}
	},
	mounted() {		
		var _this = this
		uni.getStorage({
		    key: 'servicedetails',
		    success: function (res) {
		        _this.id = res.data;
				_this.getDate();
		    }
		});
	},
	methods: {
		getDate(){
			order.details(this.id)
				.then(res => {
					this.initData=res.data;
					this.initData.image=this.imgCDNUrl + this.initData.image;
					var sku=[];
					if(this.initData.productSkuDesp){
						sku=this.initData.productSkuDesp.split(",");
						sku=sku.map(v=>{
							v=v.split(':')
							return v
						})
					}
					this.initData.sku=sku;
					uni.hideLoading();
			
				})
				.catch(err => {
					console.log(new Error('请检查网络后重试'));
				});
		},
		// 计算距离顶部的高度，均分10等分，
		backTop() {
			uni.pageScrollTo({
				scrollTop: 0,
				duration: 200
			});
		},
		pass(e){
			var _id=this.id
			var _remark=this.remark
			console.log(this.id)
			console.log(this.remark)

			var content='';
			if(e==1){
				content='您确定要通过审核吗';
			}
			if(e==0){
				content='您确定要拒绝审核吗？';
			}
			uni.showModal({
			    content: content,
				confirmColor: '#bd3c8c',
			    success: function (res) {
			        if (res.confirm) {
						var obj=new Object();
						obj.isReject=e
						obj.orderId=_id
						obj.remark=_remark
						obj.orderStatus=6
			            console.log('用户点击确定');
						order.orderAudit(obj)
							.then(res => {
								this.initData=res.data;
								this.initData.image=this.imgCDNUrl + this.initData.image;
								var sku=[];
								if(this.initData.productSkuDesp){
									sku=this.initData.productSkuDesp.split(",");
								}
								this.initData.sku=sku;
								uni.hideLoading();

							})
							.catch(err => {
								console.log(new Error('请检查网络后重试'));
							});


			        } else if (res.cancel) {
			            console.log('用户点击取消');
			        }
			    }
			});
		}
	}
};
</script>
<style lang="less" scoped>
page {
	background: #ffffff;
}
.details {
	.img {
		width: 100%;
		border: 1px solid #efeff4;
	}
	.ul {
		line-height: 72rpx;
		font-size: 24rpx;
		color: #999999;
		padding: 20rpx;
		.text {
			display: inline-block;
			width: 180rpx;
			text-align-last: justify;
			color: #333;
		}
		.li {
			display: flex;
			flex-direction: row;
			textarea,
			picker {
				font-size: 26rpx;
				width: 557rpx;
				height: 90rpx;
				line-height: 90rpx;
				border: 1px solid #e1e1e1;
				border-radius: 10rpx;
				padding: 0 27rpx;
				box-sizing: border-box;
				margin: 15rpx 0;
				background: #ffffff;
				.uni-placeholder {
					color: #999999;
				}
			}
			textarea {
				height: 300rpx;
			}
		}
		.button {
			margin-top: 50rpx;
			display: flex;
			flex-direction: row;
			view {
				width: 278rpx;
				line-height: 74rpx;
				border-radius: 37rpx;
				text-align: center;
				font-size: 28rpx;
				margin: 35rpx;
			}
			.pass {
				color: #fff;
				background: linear-gradient(80deg, #d2158a, #fc6395);
			}
			.refuse {
				color: #bd3c8c;
				border: 1px solid #bd3c8c;
			}
		}
	}
}
</style>
